package com.dingding.dubbo.framework.register;

import com.dingding.dubbo.framework.URL;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: spring-learning
 * @description:
 * @author: liugongding
 * @create: 2022-02-15 17:04
 **/
public class RemoteRegister {

    private static Map<String, List<URL>> REGISTER = new HashMap<>();

    public static void regist(String interfaceName, URL url) {
        List<URL> list = REGISTER.get(interfaceName);
        if (CollectionUtils.isEmpty(list)) {
            list = new ArrayList<>();
        }
        list.add(url);
        REGISTER.put(interfaceName, list);
    }

    public static List<URL> get(String interfaceName) {
        return REGISTER.get(interfaceName);
    }
}
